﻿using System;
using System.Windows;
using CI.Models;
using CI.Services;
using CI.Utility;
using CI.ViewModels.Industry;
using CI.ViewModels.Interfaces;
using GongSolutions.Wpf.DragDrop;

namespace CI.ViewModels.Diagramming
{
    public class CorporationVertexViewModel : IVertexViewModel
    {
        public ICorporation Corporation { get; private set; }
        public IDiagramViewModel ParentViewModel { get; private set; }

        public CorporationVertexViewModel(ICorporation corporation, IDiagramViewModel parentModel)
        {
            Corporation = corporation;
            ParentViewModel = parentModel;
        }

        public void DragOver(IDropInfo dropInfo)
        {
            if (dropInfo.Data is ICorporation)
            {
                dropInfo.Effects = DragDropEffects.Copy;
            }
            else dropInfo.IsNotHandled = true;
        }

        public void Drop(IDropInfo dropInfo)
        {
            if (dropInfo.Data is ICorporation)
            {
                ParentViewModel.Model.AddNodeWithLink(dropInfo.Data, this.Corporation);
            }
        }
    }
}